<template>
	<view class="kefu">
		<z-paging ref="paging" v-model="list" @query="queryList" :default-page-size="10">
			<view slot="top">
				<navBar title="客服" bg="#FFF"></navBar>
			</view>
			<view class="container">
				<view class="list flex_r_between" v-for="(item,index) in list" :key="index">
					<view class="left flex_center">
						<view class="avatar">
							<image :src="item.avatar" mode="aspectFill"></image>
						</view>
						<view class="text">
							<view class="nickname flex_center">
								<text class="hidden">{{ item.nickname }}</text>
								<view v-if="item.user_store_id == item.store_id">商家</view>
							</view>
							<view class="tags flex_center">
								<image class="sex"
									:src="`/static/guild/${item.gender == 1 ? 'sex_man_blue' : 'sex_women_red'}.png`">
								</image>
								<view class="age ">
									{{ item.age || '未知' }}
								</view>
							</view>
						</view>
					</view>

					<view class="right" @click="$native.toChat({
						nickName: item.nickname,
						avatar: item.avatar,
						user_id: item.user_id,
					})">
						<image :src="$util.prefix('store/icon_message.png')"></image>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	import navBar from '@/compentents/navBar/navBar.vue'
	import empty from '@/compentents/empty/empty.vue'
	import HevuLoading from '@/components/hevu-loading/hevu-loading.vue';
	export default {
		components: {
			navBar,
			empty,
			HevuLoading,
		},
		data() {
			return {
				store_id: 0,
				list: [],
				total: 1,
				page: 1,
				circle_id: 0,

				location: {
					lat: '',
					lng: '',
					province: '',
					city: '',
					area: '',
				},
			}
		},
		methods: {
			queryList(pageNo, pageSize) {
				// 0 在线
				this.$get('/provider/getProviderList', {
					page: pageNo,
					store_id: this.store_id,
					...this.location,
					limit: pageSize,
					circle_id: this.circle_id
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				})
			},
		},

		onLoad(option) {
			this.location = uni.getStorageSync('location');
			this.store_id = option.store_id;
			this.circle_id = option.circle_id;
		}
	}
</script>

<style lang="less" scoped>
	page {
		background: #FFF;
	}

	.container {
		padding: 32rpx;
		background: #FFF;
	}

	.list {
		margin-bottom: 32rpx;

		.left {
			flex: 1;

			.avatar {
				width: 112rpx;
				height: 112rpx;
				margin-right: 24rpx;

				image {
					width: 112rpx;
					height: 112rpx;
					background: #D8D8D8;
					border-radius: 56rpx;
				}
			}

			.text {
				.nickname {
					margin-bottom: 12rpx;

					text {
						font-weight: 500;
						font-size: 32rpx;
						color: #131313;
						max-width: 300rpx;
					}

					view {
						width: 72rpx;
						height: 40rpx;
						background: linear-gradient(124deg, #FFD038 0%, #FFA32B 40%, #FF6119 100%);
						border-radius: 24rpx;
						font-weight: 500;
						font-size: 24rpx;
						color: #FFFFFF;
						line-height: 40rpx;
						text-align: center;
						margin-left: 8rpx;
					}
				}

				.tags {

					.sex {
						width: 32rpx;
						height: 32rpx;
						margin-right: 6rpx;
					}

					.age {
						background: #FFF9F9;
						border-radius: 24rpx;
						border: 2rpx solid #FFDDE4;
						padding: 2rpx 12rpx;
						font-size: 24rpx;
						color: #131313;
					}
				}
			}
		}

		.right {
			width: 40rpx;
			height: 40rpx;

			image {
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
</style>